<?php
    use yii\bootstrap\ActiveForm;
    use yii\helpers\Html;
    $this->title = $title;
    $this->params['breadcrumbs'][]='>';
    $this->params['breadcrumbs'][] = ['label' => '订单管理', 'url' => ['/admin/order/list']];
    $this->params['breadcrumbs'][]='>';
    $this->params['breadcrumbs'][] = $this->title;
    $this->registerCssFile('/web/admin/css/compiled/new-user.css');
$css = <<<CSS
.span8 div{
    display:inline;
}
.help-block-error {
    color:red;
    display:inline;
}
CSS;
$this->registerCss($css);
?>
    <!-- main container -->
        <div class="container-fluid">
            <div id="pad-wrapper" class="new-user">
                <div class="row-fluid header">
                    <h3><?php echo $title?></h3>
                </div>
                <div class="row-fluid form-wrapper">
                    <!-- left column -->
                    <div class="span9 with-sidebar">
                        <div class="container">
                                <?php
                                if (Yii::$app->session->hasFlash('info')) {
                                    echo Yii::$app->session->getFlash('info');
                                }
                                $form = ActiveForm::begin([
                                    'fieldConfig' => [
                                        'template' => '<div class="span12 field-box">{label}{input}</div>{error}',
                                    ],
                                    'options' => [
                                        'class' => 'new_user_form inline-input',
                                    ],
                                ]);
                                echo $form->field($model, 'productid')->dropDownList($productlist);
                                echo $form->field($model, 'partsid')->dropDownList($partslist);
                                echo $form->field($model, 'contractNum')->dropDownList($contractlist);
                                echo $form->field($model, 'adminid')->dropDownList($adminlist);
                                echo $form->field($model, 'question')->textInput(['class' => 'span9']);
                                echo $form->field($model, 'info')->textarea(['id' => "wysi", 'class' => "span9 wysihtml5", 'style' => 'margin-left:120px']);
                                ?>
                                <div class="span11 field-box actions">
                                    <?php echo Html::submitButton('确定', ['class' => 'btn-glow primary','id'=>'orderadd']); ?>
                                    <span>OR</span>
                                    <a href="<?php echo \yii\helpers\Url::to(['order/list']);?>" class="btn btn-success">返回</a>
                                </div>
                            <?php ActiveForm::end(); ?>
                        </div>
                    </div>

                    <!-- side right column -->
                    <div class="span3 form-sidebar pull-right">
                        <div class="alert alert-info hidden-tablet">
                            <i class="icon-lightbulb pull-left"></i>
                            请在左侧表单当中填写要添加的分类，请选择好上级分类
                        </div>                        
                        <h6>商城分类说明</h6>
                        <p>该分类为无限级分类</p>
                    </div>
                </div>
            </div>
        </div>
    <!-- end main container -->
<?php
$this->registerJsFile('/web/js/jquery-1.10.1.js');
$this->registerJsFile('/web/js/layer/layer.js');
$url=\yii\helpers\Url::to(['order/ajaxlj']);
$js = <<<JS


$("#orderadd").click(function() {
  var productid =$("#order-partsid").val();
  
    if(productid==''){
           layer.alert("该产品没有零部件，请添加零部件！");
           
           return false;
     }
});

$("#order-productid").change(function(){
   var productid=$(this).val();
   $.post('$url',{"productid":productid},function(response){
       var len=response.length;
       if(len==0){
           layer.alert("该产品没有零部件，请添加零部件！");
           $("#order-partsid").html('<option value="">无零部件</option>');
           return false;
       }
       var str = '';
       for(var i=0;i<len;i++){
           str+='<option value="'+response[i].id+'">'+response[i].pname+'</option>';
       }
       $("#order-partsid").html(str);
   },'json');
   
   
});



JS;
$this->registerJs($js);


?>



